package control;

import javax.swing.JOptionPane;

import global.Global;
import model.Client;
import ui.ClientLoginWindow;

public class LoginController {
	
	private ClientLoginWindow clw;
	
	public void init() {
		clw = new ClientLoginWindow(new LoginAction());
		clw.show();
	}
	
	public void makeClient(String login) {
		try {
			Client client = new Client(login);
			ClientConnector cc = new ClientConnector(client, Global.HOST);
			cc.connect();
		} catch (Exception e) {
//			/e.printStackTrace();
			JOptionPane.showMessageDialog(null,"Erro ao tentar conectar ao servidor.","Erro",
					JOptionPane.ERROR_MESSAGE);
		}
	}
	
	public class LoginAction {
		public void login(String login) {
			makeClient(login);
		}
	}
	
}
